package com.smmisia.article.controller;

import com.smmisia.article.dto.article.ArticleUserDTO;
import com.smmisia.article.dto.article.ArticleUserInfoDTO;
import com.smmisia.article.dto.response.UpDTO;
import com.smmisia.article.dto.response.UserInfoDTO;
import com.smmisia.article.dto.response.UserResDTO;
import com.smmisia.article.request.UpdateUserRequest;
import com.smmisia.article.service.UserService;
import com.smmisia.common.Result.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user")
@Slf4j
@Tag(name = "用户管理")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/info")
    @Operation(summary = "用户信息")
    public Result<UserInfoDTO> simpleInfo(@RequestParam(required = false) Integer id) {
        return userService.simpleInfo(id);
    }

    @PostMapping("/update")
    @Operation(summary = "更新用户信息")
    public Result<String> update(@RequestBody UpdateUserRequest request) {
        return userService.updateUserInfo(request);
    }

    @GetMapping("/signature")
    @Operation(summary = "用户签名")
    public Result<String> signature(@RequestParam(required = true) Integer id) {
        return userService.getSignature(id);
    }

    /**
     * 获取推荐up
     *
     * @return
     */
    @GetMapping("/up")
    @Operation(summary = "获取推荐up")
    public Result<List<UpDTO>> upInfo() {
        return userService.upInfo();
    }

    /**
     * 获取我的点赞列表
     *
     * @return
     */
    @GetMapping("/likelist")
    @Operation(summary = "获取我的点赞列表")
    public Result<List<ArticleUserDTO>> likelist() {
        return userService.likelist();
    }

    /**
     * 获取博主人气排行榜
     */
    @GetMapping("/leaderboard")
    @Operation(summary = "获取博主人气排行榜")
    public Result<List<UserResDTO>> leaderboard() {
        return userService.leaderboard();
    }

    /**
     * 获取今日新增用户文章，总用户文章
     */
    @GetMapping("/articleUser")
    @Operation(summary = "获取今日新增用户文章，总用户文章")
    public Result<ArticleUserInfoDTO> articleUser() {
        return userService.articleUser();
    }

}